/* GUI CONVERTED from ecmt02.p (converter v1.76) Thu May 29 21:25:33 2003 */
/* ecmt02.p - PCO MAINTENANCE Copy/Close PCO                                */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.10.1.12 $                                                             */
/*V8:ConvertMode=Maintenance                                                */
/* REVISION: 7.4      LAST MODIFIED: 07/01/93   BY: pma *H013*              */
/* REVISION: 7.4      LAST MODIFIED: 05/16/96   BY: *G1VG* Julie Milligan   */
/* REVISION: 7.4      LAST MODIFIED: 07/02/96   BY: *H0LS* Russ Witt        */
/* REVISION: 7.4      LAST MODIFIED: 07/29/96   BY: *G2B2* Julie Milligan   */
/* REVISION: 8.6      LAST MODIFIED: 12/05/96   BY: *K00C* Joe Gawel        */
/* REVISION: 8.6      LAST MODIFIED: 01/02/97   BY: *K046* Joe Gawel        */
/* REVISION: 8.6      LAST MODIFIED: 04/03/97   BY: *H0VN* Russ Witt        */
/* REVISION: 8.6      LAST MODIFIED: 05/28/97   BY: *H0Z7* Julie Milligan   */
/* REVISION: 8.6      LAST MODIFIED: 10/07/97   BY: *K0LP* John Worden      */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 07/16/98   BY: *J2RT* Niranjan R.      */
/* REVISION: 8.6E     LAST MODIFIED: 11/19/98   BY: *K1Y8* Santhosh Nair    */
/* REVISION: 9.0      LAST MODIFIED: 11/26/99   BY: *K24H* Jyoti Thatte     */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder    */
/* REVISION: 9.1      LAST MODIFIED: 08/23/00   BY: *N0MZ* Mudit Mehta      */
/* REVISION: 9.1      LAST MODIFIED: 03/15/01   BY: *M100* Mark Christian   */
/* Old ECO marker removed, but no ECO header exists *F0PN*                  */
/* Revision: 1.10.1.10    BY: Thomas Fernandes  DATE: 04/24/01  ECO: *N0Y3* */
/* Revision: 1.10.1.11    BY: Katie Hilbert     DATE: 05/25/02  ECO: *P072* */
/* $Revision: 1.10.1.12 $   BY: Manjusha Inglay   DATE: 05/29/03  ECO: *N2GC*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* THE prog_types T-03 AND T-33 HAVE BEEN SWAPPED AS FOLLOWS:  */
/*      T-03 : CLOSE TO ECR/ECN       (ecm_mstr = source)      */
/*      T-33 : COPY TO ECR/ECN        (ecm_mstr = source)      */

/*NOTE: prog_type:                                             */
/*      T-01 : CONVERT ECR to ECN     (ecm_mstr = source)      */
/*      T-33 : CLOSE TO ECR/ECN       (ecm_mstr = source)      */
/*      T-03 : COPY TO ECR/ECN        (ecm_mstr = source)      */
/*      T-04 : COPY FROM ECR/ECN      (ecm_mstr = target)      */

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

{ecmtparm.i}

define new shared variable nbr_src  like ecm_nbr.
define new shared variable nbr_tgt  like ecm_nbr.
define new shared variable t_flag   like mfc_logical initial yes
                                    label "Text Data".
define new shared variable i_flag   like mfc_logical initial yes
                                    label "Item Data".
define new shared variable s_flag   like mfc_logical initial yes
                                    label "Structure/Formula Data".
define new shared variable r_flag   like mfc_logical initial yes
                                    label "Routing/Process Data".
define new shared variable p_flag   like mfc_logical initial yes
                                    label "Item Specification Data".

define shared variable local_type   like ecm_type.
define shared variable global_recid as recid.

define variable sngl_yn       like mfc_logical      no-undo.
define variable yn            like mfc_logical      no-undo.
define variable i             as integer            no-undo.
define variable cmtindx       like cmt_indx         no-undo.
define variable nbr_fr        like ecm_nbr          no-undo.
define variable id_fr         like wo_lot           no-undo.
define variable dbase_fr      like si_db            no-undo.
define variable ecn_fr        like ecm_doc_type     no-undo.
define variable nbr_to        like ecm_nbr          no-undo.
define variable id_to         like wo_lot           no-undo.
define variable dbase_to      like si_db            no-undo.
define variable ecn_to        like ecm_doc_type     no-undo.
define variable ecmassign2    like ecm_assign       no-undo.
define variable ecmtype2      like ecm_type         no-undo.
define variable l_ecmnbr      like ecm_mstr.ecm_nbr no-undo.
define variable l_pco_exists  like mfc_logical      no-undo.

define new shared stream hf.

define buffer ecm_source for ecm_mstr.
define buffer ecm_target for ecm_mstr.
define buffer cmtdet     for cmt_det.
define buffer ecddet     for ecd_det.
define buffer ecmmstr    for ecm_mstr.

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
{ecform02.i}
 SKIP(.4)  /*GUI*/
with frame form02 attr-space side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-form02-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame form02 = F-form02-title.
 RECT-FRAME-LABEL:HIDDEN in frame form02 = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame form02 =
  FRAME form02:HEIGHT-PIXELS - RECT-FRAME:Y in frame form02 - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME form02 = FRAME form02:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame form02:handle).

FORM /*GUI*/ 
   ecm_target.ecm_nbr format "x(40)"
with frame hf width 80 THREE-D /*GUI*/.


FORM /*GUI*/ 
   ecmtype2     column-label "PCC Type"
   ecmassign2   column-label "Dsgn Group"
with frame d width 29
   title color normal (getFrameTitle("PCO/PCR_TYPE_CHANGE",28))
   row 5 centered overlay attr-space THREE-D /*GUI*/.


/* SET EXTERNAL LABELS */
setFrameLabels(frame d:handle).

find ecm_mstr where recid(ecm_mstr) = ecm_recid
   exclusive-lock no-error no-wait.

if locked(ecm_mstr) then do:
   msgnbr = 7422.
   warnlvl = 4.
   return.
end.
if not available (ecm_mstr) then do:
   msgnbr = 5630.
   warnlvl = 2.
   return.
end.

{mfoutnul.i &stream_name = "hf"}

assign
   ecn_fr = ecm_doc_type
   ecn_to = ecm_doc_type.

if prog_type = "T-04" then
   assign
      nbr_to   = substring(ecm_nbr,1,8)
      id_to    = substring(ecm_nbr,9,8)
      dbase_to = substring(ecm_nbr,17,8).

else
if prog_type = "T-01" then
   assign
      nbr_fr   = substring(ecm_nbr,1,8)
      id_fr    = substring(ecm_nbr,9,8)
      dbase_fr = substring(ecm_nbr,17,8)
      ecn_to   = "PCO"
      nbr_to   = substring(ecm_nbr,1,8)
      id_to    = substring(ecm_nbr,9,8)
      dbase_to = substring(ecm_nbr,17,8).

else
   assign
      nbr_fr   = substring(ecm_nbr,1,8)
      id_fr    = substring(ecm_nbr,9,8)
      dbase_fr = substring(ecm_nbr,17,8).

if prog_type = "T-33" or prog_type = "T-04" then
   i_flag = no.
if prog_type = "T-01" then
   p_flag = no.

display
   {ecform02.i}
with frame form02.

if prog_type = "T-04" then
   display
      "" @ ecn_fr
   with frame form02.
else
if prog_type = "T-03" or prog_type = "T-33" then
   display
      "" @ ecn_to
   with frame form02.

loop1:
repeat with frame form02 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


   msgnbr = 5630.
   warnlvl = 2.

   update
      nbr_fr   when (prog_type = "T-04")
      id_fr    when (prog_type = "T-04")
      dbase_fr when (prog_type = "T-04")
      nbr_to   when (prog_type = "T-03" or prog_type = "T-33")
      id_to    when (prog_type = "T-03" or prog_type = "T-33")
      dbase_to when (prog_type = "T-03" or prog_type = "T-33")
      ecn_to   when (prog_type = "T-03" or prog_type = "T-33")
      t_flag   when (prog_type = "T-33" or prog_type = "T-04")
      i_flag   when (prog_type = "T-33" or prog_type = "T-04")
      s_flag   when (prog_type = "T-33" or prog_type = "T-04")
      r_flag   when (prog_type = "T-33" or prog_type = "T-04")
      p_flag   when (prog_type = "T-33" or prog_type = "T-04")
   with frame form02
   editing:

      if prog_type = "T-04" then do:
         global_lot = nbr_fr.
         {mfnp.i ecm_mstr nbr_fr ecm_nbr nbr_fr ecm_nbr ecm_mstr}
         if recno <> ? then
            display
               substring (ecm_nbr,1,8) @ nbr_fr
               substring(ecm_nbr, 9,8) @ id_fr
               substring(ecm_nbr,17,8) @ dbase_fr
               ecm_doc_type @ ecn_fr
            with frame form02.
      end.
      else do:
         global_lot = nbr_to.
         {mfnp.i ecm_mstr nbr_to ecm_nbr nbr_to ecm_nbr ecm_mstr}
         if recno <> ? then
            display
               substring (ecm_nbr,1,8) @ nbr_to
               substring(ecm_nbr, 9,8) @ id_to
               substring(ecm_nbr,17,8) @ dbase_to
               ecm_doc_type @ ecn_to
            with frame form02.
      end.

      /* VERIFYING THE DOCUMENT TYPE TO BE EITHER 'PCO' OR 'PCR' */
      if ((frame-field          = "t_flag")
      and (keyfunction(lastkey) = "RETURN"))
       or (keyfunction(lastkey) = "GO")
      then do:

         if  (input ecn_to <> "PCO")
         and (input ecn_to <> "PCR")
         then do:

            /* DOCUMENT TYPE MUST BE PCR OR PCO */
            {pxmsg.i &MSGNUM=2139 &ERRORLEVEL=3}
            next-prompt ecn_to with frame form02.
            next.

         end. /* IF (INPUT ecn_to) <> ... */

      end. /* IF (FRAME-FIELD = ... */
   end.

   if (nbr_to + id_to + dbase_to  = "") or
      (nbr_fr + id_fr + dbase_fr = "")
   then do:
      {pxmsg.i &MSGNUM=40 &ERRORLEVEL=3}
      undo, retry.
   end.

   /*ECM_MSTR IS THE TARGET*/
   if prog_type = "T-04" then do:

      /*DISPLAY ECR or ECN*/
      find ecm_source where
         ecm_source.ecm_nbr = string(nbr_fr, "x(8)")
                            + string(id_fr, "x(8)")
                            + string(dbase_fr, "x(8)")
         no-lock no-error no-wait.
      if available ecm_source then do:
         ecn_fr = ecm_source.ecm_doc_type.
         display ecn_fr.
      end.

      find ecm_target where recid(ecm_target) = ecm_recid
         exclusive-lock no-error no-wait.
      find ecm_source where
         ecm_source.ecm_nbr = string(nbr_fr, "x(8)")
                            + string(id_fr, "x(8)")
                            + string(dbase_fr, "x(8)")
         exclusive-lock no-error no-wait.
      if locked (ecm_source) then do:
         {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=4} /*RECORD IS LOCKED*/
         undo, retry.
      end.
      if not available (ecm_source) then do:
         {pxmsg.i &MSGNUM=5633 &ERRORLEVEL=3} /*SOURCE RECORD DOES NOT EXIST*/
         undo, retry.
      end.

      display
         ecm_source.ecm_doc_type @ ecn_fr.

   end. /* if prog_type = "T-04" */

   /*CONVERTING ECR TO ECN OF SAME NUMBER*/
   else
   if prog_type = "T-01" and nbr_fr = nbr_to and id_fr = id_to
      and dbase_fr = dbase_to then do:

      yn = yes.
      /*BEGIN PROCESS*/
      {pxmsg.i &MSGNUM=5647 &ERRORLEVEL=1 &CONFIRM=yn}
      if not yn then undo, return.

      nbr_tgt = string(nbr_to, "x(8)")
              + string(id_to, "x(8)")
              + string(dbase_to, "x(8)")
              + "*".

      if can-find (ecm_target where ecm_target.ecm_nbr = nbr_tgt)
      then do:
         msgnbr = 3746. /* PCR has already been converted */
         warnlvl = 4.
         return.
      end.

      find ecm_source where recid(ecm_source) = ecm_recid
         exclusive-lock no-error no-wait.

      find ecm_target where recid(ecm_target) = ecm_recid
         exclusive-lock no-error no-wait.

      display stream hf
         ecm_target
      with frame hf.
      display stream hf
         nbr_tgt @ ecm_target.ecm_nbr
      with frame hf.

      create ecm_target.
      assign ecm_target.

      assign
         ecm_target.ecm_doc_type   = "PCO"
         ecm_target.ecm_userid     = global_userid
         ecm_target.ecm_mod_date   = today
         ecm_target.ecm_open_date  = today
         ecm_target.ecm_sub_date   = ?
         ecm_target.ecm_rel_date   = ?
         ecm_target.ecm_appr_date  = ?
         ecm_target.ecm_eff_date   = ?
         ecm_target.ecm_end_date   = ?
         ecm_target.ecm_close_date = ?.

   end.

   /*ECM_MSTR IS THE SOURCE*/
   else do:
      /*DISPLAY ECR or ECN*/
      find ecm_target where
         ecm_target.ecm_nbr = string(nbr_to, "x(8)")
                            + string(id_to, "x(8)")
                            + string(dbase_to, "x(8)")
         no-lock no-error no-wait.

      if available ecm_target and ecm_target.ecm_doc_type <> ecn_to
      then do:
         /* # already exists as # */
         {pxmsg.i &MSGNUM=5649 &ERRORLEVEL=2
                  &MSGARG1="trim(ecm_target.ecm_nbr)"
                  &MSGARG2="ecm_target.ecm_doc_type"}
         pause.
         display ecn_to.
      end.

      find ecm_source where recid(ecm_source) = ecm_recid
         exclusive-lock no-error no-wait.
      find ecm_target where
         ecm_target.ecm_nbr = string(nbr_to, "x(8)")
                            + string(id_to, "x(8)")
                            + string(dbase_to, "x(8)")
         exclusive-lock no-error no-wait.
      if locked (ecm_target) then do:
         {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=4} /*RECORD IS LOCKED*/
         undo, retry.
      end.
      else if available (ecm_target) then do:

         if ecm_source.ecm_doc_type = "PCO"
            and ecm_target.ecm_doc_type = "PCR"
         then do:
            {pxmsg.i &MSGNUM=2164 &ERRORLEVEL=3} /*Cannot close PCO to PCR*/
            undo, retry.
         end.
         else do:
            yn = no.
            /*TARGET EXISTS. CONTINUE?*/
            {pxmsg.i &MSGNUM=5632 &ERRORLEVEL=2 &CONFIRM=yn}
            if not yn then undo, retry.
         end.
      end.
      else if prog_type = "T-03" and not available ecm_target then do:
         /* PCO does not exist */
         {pxmsg.i &MSGNUM=2155 &ERRORLEVEL=3}
         undo, retry.
      end.

      else do:

         find ecm_target where recid(ecm_target) = ecm_recid
            exclusive-lock no-error no-wait.
         display stream hf
            ecm_target
         with frame hf.

         display stream hf
              string(nbr_to, "x(8)")
            + string(id_to, "x(8)")
            + string(dbase_to,"x(8)")
            @ ecm_target.ecm_nbr with frame hf.

         create ecm_target.
         assign ecm_target.
         assign
            ecm_target.ecm_nbr = string(nbr_to, "x(8)")
                               + string(id_to, "x(8)")
                               + string(dbase_to, "x(8)")
            ecm_target.ecm_doc_type   = ecn_to
            ecm_target.ecm_userid     = global_userid
            ecm_target.ecm_mod_date   = today
            ecm_target.ecm_open_date  = today
            ecm_target.ecm_sub_date   = ?
            ecm_target.ecm_rel_date   = ?
            ecm_target.ecm_appr_date  = ?
            ecm_target.ecm_eff_date   = ?
            ecm_target.ecm_end_date   = ?
            ecm_target.ecm_close_date = ?.

      end.

   end.

   if ecm_target.ecm_rel_date <> ? then do:
      /* # PCR/PCO #.  Detail modification not allowed  */
      {pxmsg.i &MSGNUM=2157 &ERRORLEVEL=3 &MSGARG1= ""target""
               &MSGARG2= getTermLabel(""RELEASED"",15)}
      undo, retry.
   end.
   if ecm_target.ecm_sub_date <> ? then do:
      /* # PCR/PCO #.  Detail modification not allowed  */
      {pxmsg.i &MSGNUM=2157 &ERRORLEVEL=3 &MSGARG1= ""target""
               &MSGARG2= getTermLabel(""SUBMITTED"",15)}
      undo, retry.
   end.
   if ecm_target.ecm_close_date <> ? then do:
      /* # PCR/PCO #.  Detail modification not allowed  */
      {pxmsg.i &MSGNUM=2157 &ERRORLEVEL=3 &MSGARG1= ""target""
               &MSGARG2= getTermLabel(""CLOSED"",15)}
      undo, retry.
   end.

   assign
      ecn_fr  = ecm_source.ecm_doc_type
      ecn_to  = ecm_target.ecm_doc_type
      nbr_src = ecm_source.ecm_nbr
      nbr_tgt = ecm_target.ecm_nbr.

   display
      ecn_fr
      ecn_to.

   if nbr_src = nbr_tgt then do:
      pause 1 no-message.
      {pxmsg.i &MSGNUM=172 &ERRORLEVEL=3}  /*No changes were made*/
      undo loop1, retry.
   end.

   /* THE FOLLOWING CODE ENSURES THAT AT ANY GIVEN MOMENT OF TIME   */
   /* THERE WILL BE ONLY ONE UNDISTRIBUTED PCO REFERENCING AN ITEM. */
   /* HOWEVER THIS RULE WILL APPLY TO PCOs ONLY. THIS IMPLIES THAT  */
   /* IT IS LEGAL FOR MULTIPLE PCRs TO REFERENCE THE SAME ITEM.     */

   if i_flag
      and ecn_to      = "PCO"
      and not (ecn_fr = "PCO"
      and prog_type   = "T-03")
   then do:

      for each ecd_det
            fields (ecd_nbr ecd_part)
            where ecd_det.ecd_nbr =  nbr_src
            no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.


         /* PROCEDURE same_item_multiple_pco EXISTS IN ecstatus.i */

         run same_item_multiple_pco (input  ecd_det.ecd_part,
                                     output l_ecmnbr,
                                     output l_pco_exists).

         if l_pco_exists
         then do:

            do on endkey undo, leave:
               /* ITEM BEING MODIFIED ON <PCO> <PCO NUMBER> */
               {pxmsg.i &MSGNUM=5650 &ERRORLEVEL=3
                        &MSGARG1=""PCO"" &MSGARG2="l_ecmnbr"}
               pause.
            end. /* DO ON ENDKEY UNDO, LEAVE */

            if prog_type = "T-01"
            then
               undo loop1, return.
            else
               undo loop1, retry.

         end. /* IF l_pco_exists */

      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR EACH ecd_det */

   end. /* IF i_flag */

   /*SEPARATE ECM TRANSACTION COMMENTS*/
   if ecm_source.ecm_cmtindx <> 0 and
      ecm_source.ecm_cmtindx = ecm_target.ecm_cmtindx then do:
      {gpcmtcpy.i &old_index = ecm_source.ecm_cmtindx
                  &new_index = ecm_target.ecm_cmtindx
                  &counter   = i}
   end.
   assign
      msgnbr = 5630
      warnlvl = 2
      ecmtype2 = ecm_mstr.ecm_type
      ecmassign2 = ecm_mstr.ecm_assign.

   pause 0.
   do on error undo, leave on endkey undo loop1, retry loop1:
/*GUI*/ if global-beam-me-up then undo, leave.


      {gprun.i ""ecmt02a.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


      if prog_type = "T-33"
         or prog_type = "T-03"
         or prog_type = "T-01" then
         block-t:
      do on error undo:
/*GUI*/ if global-beam-me-up then undo, leave.


         global_recid = ?.

         if prog_type = "T-01" or prog_type = "T-33" then do:

            find pct_mstr where pct_type = ecmtype2 and
               pct_dsgn_grp = ecmassign2
               no-lock no-error.

            if available pct_mstr then
               display
                  pct_doc_type no-label
               with frame d.
            update
               ecmtype2
               ecmassign2
            with frame d
            editing:
               local_type = input ecmtype2.
               if frame-field = "ecmtype2" then do:
                  /* FIND NEXT/PREVIOUS RECORD */
                  {mfnp.i pct_mstr ecmtype2 pct_type ecmtype2
                     pct_type pct_type}
                  if global_recid <> ? then do:
                     recno = global_recid.

                     find pct_mstr where recid(pct_mstr) = recno
                        no-lock no-error.
                     global_recid = ?.
                  end.

                  if recno <> ? then
                     display
                        pct_type     @ ecmtype2
                        pct_dsgn_grp @ ecmassign2
                        pct_doc_type no-label
                     with frame d.
               end.
               else do:
                  readkey.
                  apply lastkey.
               end.
            end. /* update with frame d */

            if not can-find (first pct_mstr where pct_type = ecmtype2)
            then do:
               /* Type/design group does not exist */
               {pxmsg.i &MSGNUM=5604 &ERRORLEVEL=3}
               next-prompt ecmtype2 with frame d.
               undo, retry.
            end.

            else
            if not can-find (pct_mstr where pct_type = ecmtype2
               and pct_dsgn_grp = ecmassign2)
            then do:
               /* Type/design group does not exist */
               {pxmsg.i &MSGNUM=5604 &ERRORLEVEL=3}
               next-prompt ecmassign2 with frame d.
               undo, retry.
            end.

            find pct_mstr where pct_type = ecmtype2 and
               pct_dsgn_grp = ecmassign2
               no-lock no-error.
            if available pct_mstr then
               display
                  pct_doc_type no-label
               with frame d.

            if available pct_mstr and
               pct_doc_type <> ecm_target.ecm_doc_type
            then do:
               /* ECN/ECR type does not match ECN/ECR requirement */
               {pxmsg.i &MSGNUM=2176 &ERRORLEVEL=2}
               hide message.
            end.

            yn = no.
            if ecmtype2 <> ecm_mstr.ecm_type or
               ecmassign2 <> ecm_mstr.ecm_assign
            then do:
               /* ECN type and design group modified.  Continue?*/
               {pxmsg.i &MSGNUM=2166 &ERRORLEVEL=1 &CONFIRM=yn}
            end.
            else do:
               /* ECN type and design group not modified.  Continue?*/
               {pxmsg.i &MSGNUM=2179 &ERRORLEVEL=1 &CONFIRM=yn}
            end.

            if not yn then undo block-t, retry block-t.

            hide frame d.
            assign
               global_recid = ?
               ecm_target.ecm_type = ecmtype2
               ecm_target.ecm_assign = ecmassign2.

         end. /* if prog_type = "T-01" */

         if prog_type = "T-01" or prog_type = "T-03" then do:
            assign
               ecm_source.ecm_end_date = today
               ecm_source.ecm_nbr_to = nbr_tgt
               ecm_target.ecm_nbr_fr = nbr_src.
            if ecm_source.ecm_close_date = ? then
               ecm_source.ecm_close_date = today.
         end.

         if prog_type = "T-01" then do:

            ecm_target.ecm_nbr = nbr_src + "**".
            if recid(ecm_target) = -1 then .
            ecm_source.ecm_nbr = nbr_tgt.
            release ecm_source.
            ecm_target.ecm_nbr = nbr_src.

            for each rsu_mstr where
                  rsu_doc_nbr =   substring(nbr_src,1,25)
                  exclusive-lock:
               rsu_doc_nbr = string(rsu_doc_nbr,"x(24)") + "*".
            end.

         end.  /* if prog-type = "T01"  */

      end.
/*GUI*/ if global-beam-me-up then undo, leave.
     /* block-t            */

      msgnbr = 1107.
      warnlvl = 1.

      if prog_type = "T-01" or prog_type = "T-33" then do:

         /* ASSIGNING PCT_MSTR VALUE TO ECM_TARGET TABLE */
         for first pct_mstr
            fields(pct_approval pct_distr pct_doc_type
                   pct_dsgn_grp pct_type)
            where pct_type     = ecmtype2
              and pct_dsgn_grp = ecmassign2
            no-lock:
            assign
               ecm_target.ecm_approval = pct_approval
               ecm_target.ecm_distr    = pct_distr.
         end. /* FOR FIRST PCT_MSTR */

         global_recid = recid(ecm_target).
         leave loop1.

      end.
/*GUI*/ if global-beam-me-up then undo, leave.


   end.
/*GUI*/ if global-beam-me-up then undo, leave.
    /* end do  */

   {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=warnlvl}

end. /*loop1*/

msgnbr = 0.
warnlvl = 0.

/* CONTAINS INTERNAL PROCEDURE same_item_multiple_pco */
{ecstatus.i}
